<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Function WriteToLogFile(strLogMessage)  'example use of Err object
  ForAppending = 8        'ASP doesn't recognize this is some releases
  WriteToLogFile = False  'default return value of function 
  On Error Resume Next
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objLogFile = objFSO.OpenTextFile("C:\Logfiles\MyLog.txt", ForAppending)
  Select Case Err.Number
    Case 0            'OK, do nothing
    Case 5, 50, 53    'standard file or path not found errors
      'create the custom error values and raise it back to the system
      intErrNumber = vbObjectError + 1073  'create a custom error number
      strErrDescription = "Log file has been deleted or moved."
      strErrSource = "WriteToLogFile function"
      Err.Raise intErrNumber,  strErrSource, strErrDescription
      Exit Function
    Case Else      'some other error
      'raise the standard error back to the system
      Err.Raise Err.Number, Err.Source, Err.Description
      Exit Function
  End Select
  objLogFile.WriteLine(strLogMessage)
  objLogFile.Close
  WriteToLogFile = True
End Function
</SCRIPT>
